package main

import (
	"context"
	"example-damo/global"
	"example-damo/pro"
	"fmt"
	"google.golang.org/grpc"
	"log"
)

func main() {
	//通过grpc 库 建立一个连接
	ADDRESS := global.ServerAddress[1]
	conn, err := grpc.Dial(ADDRESS, grpc.WithInsecure())
	if err != nil {
		return
	}
	defer conn.Close()
	//通过刚刚的连接 生成一个client对象。
	c := pro.NewGreeterClient(conn)
	fmt.Println(conn)
	//调用服务端推送流
	reqstreamData := &pro.StreamReqData{Data: "aaa"}
	res, _ := c.GetStream(context.Background(), reqstreamData)
	for {
		aa, err := res.Recv()
		if err != nil {
			log.Println(err)
			break
		}
		log.Println(aa)
	}
}
